package pl.andrzejag.seleniumtests;

import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.regex.Pattern;

public class SeleniumTestRC extends SeleneseTestCase {
	@Before
	public void setUp() throws Exception {
		selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://code.google.com/");
		selenium.start();
	}

	@Test
	public void testSeleniumTestRC() throws Exception {
		selenium.open("/p/selenium/");
		selenium.click("link=Downloads");
		selenium.waitForPageToLoad("30000");
		verifyTrue(selenium.isTextPresent("Current downloads"));
		selenium.click("link=Wiki");
		selenium.waitForPageToLoad("30000");
		verifyTrue(selenium.isTextPresent("Current pages"));
		selenium.click("link=Issues");
		selenium.waitForPageToLoad("30000");
		verifyTrue(selenium.isTextPresent("Open issues"));
		selenium.click("id=searchq");
		selenium.type("id=searchq", "bug");
		selenium.click("css=span.inIssueList > form > input[type=\"submit\"]");
		selenium.waitForPageToLoad("30000");
		selenium.click("link=Source");
		selenium.waitForPageToLoad("30000");
		verifyTrue(selenium.isTextPresent("Command-line access"));
		verifyTrue(selenium.isTextPresent("client programs and plug-ins"));
		assertEquals("client programs and plug-ins", selenium.getText("link=client programs and plug-ins"));
		assertEquals("Source Checkout - selenium - Browser automation framework - Google Project Hosting", selenium.getTitle());
	}

	@After
	public void tearDown() throws Exception {
		selenium.stop();
	}
}
